function getCarList(){
    let data = []
    let totalPrice = 0
    for(let i = 0; i < 10; i++){
        data.push(
            Mock.mock({
                "image" : Random.image(),
                "pet_name" : Random.cname(),
                "price" : Random.float(100,500,2,2),
                "number" : Random.integer(1,10),
                "stock" : Random.integer(1,100),
            })
        )

        totalPrice += data[i].price * data[i].number
    }

    totalPrice = Number(totalPrice).toFixed(2)

    json = {
        data,
        totalPrice,
        'code' : 200
    }

    return json
}

function getClearCarRes(){
    json = {
        'code' : 200,
        'msg' : '清除成功'
    }

    return json
}

function getChangeRes(){
    json = {
        'code' : 200,
        'msg' : '购买成功'
    }

    return json
}

function getPayRes(){
    json = {
        'code' : 200,
        'msg' : '购买成功'
    }

    return json
}

Random = Mock.Random

Mock.mock("http://localhost/car.php", 'post', getCarList)

Mock.mock("http://localhost/clear_car.php", 'post', getClearCarRes)

Mock.mock("http://localhost/del_car.php", 'post', getClearCarRes)

Mock.mock("http://localhost/pay.php", 'post', getPayRes)

Mock.mock("http://localhost/change_number.php", 'post', getChangeRes)

